#pragma once

#define _GNU_SOURCE

#include <linux/types.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <memory.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <stdint.h>
#include <assert.h>
#include <sys/ptrace.h>

/*=================================
 *  自定义打印输出
 ==================================*/
#define INFO_OUTPUT         3
#define WARNING_OUTPUT      2
#define DEBUG_OUTPUT        1
#define ERROR_OUTPUT        0

#define DEBUG
#define DEBUG_LEVEL         INFO_OUTPUT

#define PRINT(fmt, ...) do{ \
    fprintf(stdout, "[Info] (%s:%d->%s): " fmt, __FILE__, __LINE__, __func__, ##__VA_ARGS__); \
}while(0)

#define INFO_PRINT(fmt, ...) do{ \
    if(DEBUG_LEVEL>=INFO_OUTPUT){ \
        fprintf(stdout, "[Info] (%s:%d->%s): " fmt, __FILE__, __LINE__, __func__, ##__VA_ARGS__); \
    } \
}while(0)

#define WARNING_PRINT(fmt, ...) do{ \
    if(DEBUG_LEVEL>=WARNING_OUTPUT){ \
        fprintf(stdout, "[Warning] (%s:%d->%s): " fmt, __FILE__, __LINE__, __func__, ##__VA_ARGS__); \
    } \
}while(0)

#define DEBUG_PRINT(fmt,...) do{ \
    if(DEBUG_LEVEL>=DEBUG_OUTPUT){ \
        fprintf(stdout, "[Debug] (%s:%d->%s): " fmt, __FILE__, __LINE__, __func__, ##__VA_ARGS__); \
    } \
}while(0)

#define ERROR_PRINT(fmt,...) do{ \
    if(DEBUG_LEVEL>=DEBUG_OUTPUT){ \
        fprintf(stdout, "[Error] (%s:%d->%s): " fmt, __FILE__, __LINE__, __func__, ##__VA_ARGS__); \
    } \
}while(0)